package com.shouer.doc.ui.photopreview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;

import com.shouer.doc.R;
import com.shouer.doc.event.RemoteLoginEvent;
import com.shouer.doc.event.RongRemoteLoginEvent;
import com.shouer.doc.widget.MultiTouchViewPager;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import me.relex.circleindicator.CircleIndicator;

/**
 * Created by YYY on 2016/12/10.
 */

public class PhotoPreviewActivity extends AppCompatActivity{

    @BindView(R.id.view_pager)
    protected MultiTouchViewPager viewPager;
    @BindView(R.id.indicator)
    protected CircleIndicator indicator;

    private List<String> photos;

    @Override
    public void onCreate(Bundle bundle)
    {
        super.onCreate(bundle);
        requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
        setContentView(R.layout.activity_photo_review_layout);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
        getIntentDatas();
        viewPager.setAdapter(new PhotoPreViewAdapter(this,photos));
        indicator.setViewPager(viewPager);
    }

    private void getIntentDatas()
    {
        photos= (List<String>) getIntent().getSerializableExtra("photos");
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(RemoteLoginEvent event)
    {
        finish();
    }

    /**
     * 账号异地登录 关闭Activity
     * */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(RongRemoteLoginEvent event) {
        finish();
    }
}
